﻿using LS.Nc6.Web.Entry.ViewModel.UI;

namespace LS.Nc6.Web.Entry.ViewComponents
{
    public class CompIntrodViewComponent : ViewComponent
    {
        private readonly ICmsChannelService _cmsChannelService;
        private readonly ICmsContentService _contentService;
        public CompIntrodViewComponent(ICmsChannelService cmsChannelService , ICmsContentService contentService)
        {
            _cmsChannelService= cmsChannelService;
            _contentService = contentService;
        }
        public  async Task<IViewComponentResult> InvokeAsync(long id)
        {
            CompanyIntrodVm companyvm = new CompanyIntrodVm();
            var contentmodel=await  _contentService.GetModelAsync(a => a.ChannelId == id);
            if (contentmodel!=null)
            {
                companyvm.Title = contentmodel.Title;
                companyvm.Content= contentmodel.Body;
            }
            return View(companyvm);
        }
      
    }
}
